﻿using MongoDB.Driver;
using Sustainalytics.ClientDW.Synchronization.SyncESGData.AbstractClassesAndInterfaces;
using Sustainalytics.Synchronization.Interface;
using Sustainalytics.SharedEntities.EsgResearch;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.AnalystLogic
{
    public class AnalystCommand : SyncEsgCommand<Analyst>
    {
        private readonly IMongoCollection<Analyst> analystCollection;

        public AnalystCommand(IMongoCollection<Analyst> analystCollection, ILogger logger) : base(logger)
        {
            this.analystCollection = analystCollection;
        }

        protected override async Task<DeleteResult> DeleteAssociatedRecordsAsync(IEnumerable<Guid> companiesIds = null, Guid? additionalDiscriminator = null)
        {
            return await analystCollection.DeleteManyAsync(Builders<Analyst>.Filter.Empty).ConfigureAwait(false);
        }

        protected override async Task InsertRecordsAsync(IEnumerable<Analyst> entities)
        {
            await analystCollection.InsertManyAsync(entities).ConfigureAwait(false);
        }
    }
}
